<?php
namespace app\index\validate;

use think\Validate;

class User extends Validate
{
    protected $rule = [
        'username'         => 'require|unique:user',
        'password'         => 'require',
        'password2' => 'confirm:password',
        'mobile'           => 'number|length:11',
        'email'            => 'email',
    ];

    protected $message = [
        'username.require'         => '请输入用户名',
        'username.unique'          => '用户名已存在',
        'password.require'         => '密码不能为空',
        'password2.confirm' => '两次输入密码不一致',
        'mobile.number'            => '手机号格式错误',
        'mobile.length'            => '手机号长度错误',
        'email.email'              => '邮箱格式错误',
    ];
    
    protected $scene = [
        'login'  =>  ['username'=>'require','password'],
        'register1'  =>  ['mobile','username','yzm','password','password2'],
        'register2'  =>  ['email','username','password','password2'],
    ]; 
}